# RUN: llc -filetype=obj -start-after=patchable-function -O3 %s -o - | llvm-dwarfdump -v - | FileCheck %s

# CHECK-LABEL: .debug_info contents:

# CHECK-LABEL: DW_TAG_GNU_call_site
# CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x[[BAR_ADDR:[0-9a-f]+]] => {0x{{0*}}[[BAR_ADDR]]} "bar")
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x00000008 ".text")

--- |
  ; ModuleID = 'bundled-call-pr44001.ll'
  source_filename = "bundled-call-pr44001.c"
  target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
  target triple = "hexagon-unknown-unknown-elf"
  
  define dso_local i32 @foo(i32 %cond) local_unnamed_addr !dbg !12 {
  entry:
    call void @llvm.dbg.value(metadata i32 %cond, metadata !14, metadata !DIExpression()), !dbg !15
    %call = tail call i32 @bar(i32 %cond), !dbg !16
    %add = add nsw i32 %call, 1, !dbg !17
    ret i32 %add, !dbg !18
  }
  
  declare !dbg !4 dso_local i32 @bar(i32) local_unnamed_addr
  
  ; Function Attrs: nounwind readnone speculatable willreturn
  declare void @llvm.dbg.value(metadata, metadata, metadata)
  
  !llvm.dbg.cu = !{!0}
  !llvm.module.flags = !{!8, !9, !10}
  !llvm.ident = !{!11}
  
  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
  !1 = !DIFile(filename: "bundled-call-pr44001.ll", directory: "/")
  !2 = !{}
  !3 = !{!4}
  !4 = !DISubprogram(name: "bar", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
  !5 = !DISubroutineType(types: !6)
  !6 = !{!7, !7}
  !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  !8 = !{i32 2, !"Dwarf Version", i32 4}
  !9 = !{i32 2, !"Debug Info Version", i32 3}
  !10 = !{i32 1, !"wchar_size", i32 4}
  !11 = !{!"clang version 10.0.0"}
  !12 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !5, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
  !13 = !{!14}
  !14 = !DILocalVariable(name: "cond", arg: 1, scope: !12, file: !1, line: 4, type: !7)
  !15 = !DILocation(line: 0, scope: !12)
  !16 = !DILocation(line: 5, column: 10, scope: !12)
  !17 = !DILocation(line: 5, column: 20, scope: !12)
  !18 = !DILocation(line: 5, column: 3, scope: !12)

...
---
name:            foo
alignment:       16
tracksRegLiveness: true
frameInfo:
  maxAlignment:    1
  adjustsStack:    true
  hasCalls:        true
  maxCallFrameSize: 0
machineFunctionInfo: {}
body:             |
  bb.0.entry:
    liveins: $r0
  
    DBG_VALUE $r0, $noreg, !14, !DIExpression(), debug-location !15
    DBG_VALUE $r0, $noreg, !14, !DIExpression(), debug-location !15
    DBG_VALUE $r0, $noreg, !14, !DIExpression(), debug-location !15
    BUNDLE implicit-def $r29, implicit-def $r30, implicit-def dead $pc, implicit-def dead $r31, implicit-def $r0, implicit $r29, implicit killed $framekey, implicit killed $framelimit, implicit killed $r30, implicit killed $r31, implicit $r0, debug-location !16 {
      $r29 = S2_allocframe $r29, 0, implicit-def $r30, implicit killed $framekey, implicit killed $framelimit, implicit killed $r30, implicit killed $r31, debug-location !16 :: (store (s32) into stack)
      J2_call @bar, hexagoncsr, implicit-def dead $pc, implicit-def dead $r31, implicit internal killed $r29, implicit $r0, implicit-def $r29, implicit-def $r0, debug-location !16
    }
    BUNDLE implicit-def dead $r0, implicit-def $d15, implicit-def $r30, implicit-def $r31, implicit-def $pc, implicit-def $r29, implicit $r0, implicit killed $r30, implicit killed $framekey, debug-location !17 {
      renamable $r0 = nsw A2_addi renamable $r0, 1, debug-location !17
      $d15 = L4_return killed $r30, implicit-def $pc, implicit-def $r29, implicit killed $framekey, implicit-def dead $pc, implicit internal killed $r0, debug-location !18
    }

...
